package cn.cs.service.impl;

import cn.cs.client.RepairBbsTypeClient;
import cn.cs.common.Constants;
import cn.cs.common.EmptyUtils;
import cn.cs.common.Page;
import cn.cs.pojo.RepairBbsType;
import cn.cs.service.RepairBbsTypeService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Service
public class RepairBbsTypeServiceImpl implements RepairBbsTypeService {

    @Resource
    private RepairBbsTypeClient repairBbsTypeClient;

    public RepairBbsType getRepairBbsTypeById(String id) throws Exception {
        return repairBbsTypeClient.getRepairBbsTypeById(id);
    }

    public List<RepairBbsType> getRepairBbsTypeListByMap(Map<String, Object> param) throws Exception {
        return repairBbsTypeClient.getRepairBbsTypeListByMap(param);
    }

    public Integer getRepairBbsTypeCountByMap(Map<String, Object> param) throws Exception {
        return repairBbsTypeClient.getRepairBbsTypeCountByMap(param);
    }

    public Integer addRepairBbsType(RepairBbsType repairBbsType) throws Exception {
        return repairBbsTypeClient.addRepairBbsType(repairBbsType);
    }

    public Integer modifyRepairBbsType(RepairBbsType repairBbsType) throws Exception {
        return repairBbsTypeClient.modifyRepairBbsType(repairBbsType);
    }

    public Integer deleteRepairBbsTypeById(String id) throws Exception {
        return repairBbsTypeClient.deleteRepairBbsTypeById(id);
    }

    public Page<RepairBbsType> queryRepairBbsTypePageByMap(Map<String, Object> param, Integer pageNo, Integer pageSize) throws Exception {
        Integer total = repairBbsTypeClient.getRepairBbsTypeCountByMap(param);
        pageNo = EmptyUtils.isEmpty(pageNo) ? Constants.DEFAULT_PAGE_NO : pageNo;
        pageSize = EmptyUtils.isEmpty(pageSize) ? Constants.DEFAULT_PAGE_SIZE : pageSize;
        Page page = new Page(pageNo, pageSize, total);
        param.put("beginPos", page.getBeginPos());
        param.put("pageSize", page.getPageSize());
        List<RepairBbsType> repairBbsTypeList = repairBbsTypeClient.getRepairBbsTypeListByMap(param);
        page.setRows(repairBbsTypeList);
        return page;
    }

}
